package de.baumann.browser.activitys

import android.content.Context
import android.content.Intent
import android.util.Log
import de.baumann.browser.R
import de.baumann.browser.base.BaseOdinActivity
import de.baumann.browser.iview.IBindPoolView
import de.baumann.browser.present.BindPoolPresenter
import kotlinx.android.synthetic.main.activity_bind_pool.*
import kotlinx.android.synthetic.main.include_tool_bar.*

class BindPoolActivity : BaseOdinActivity<IBindPoolView, BindPoolPresenter>(), IBindPoolView {
    companion object {
        fun startBindPoolActivity(context: Context) {
            context.startActivity(Intent(context, BindPoolActivity::class.java))
        }
    }


    override fun getLayout(): Int {
        return R.layout.activity_bind_pool
    }

    override fun getTitleText(): String {
        return "绑定矿池"
    }

    private var invitation = ""
    override fun initView() {
        initToolbar(commToolBar, commTitle)
    }

    override fun initData() {
        btnBindPool.setOnClickListener {
            invitation = tvInvitation.text.toString().trim()
            if (invitation.length < 6) {
                showShortToast("请输入6位邀请码")
            } else {
                presenter.inviteCode()
                finish()
            }

        }
    }

    override fun createPresenter(): BindPoolPresenter {
        return BindPoolPresenter()
    }

    override fun createView(): IBindPoolView {
        return this
    }

    override fun getInvitation(): String {
        return invitation
    }

    override fun finishCode() {
        showShortToast("绑定成功")
    }
}